package classics;
//定义类
public class BankAccount {
    //定义属性
   private int accountNumber;
   private String accountPassword;
   private double balance;
   //定义构造方法，进行初始化
   public BankAccount(int accountNumber,String accountPassword){
       this.accountNumber = accountNumber;
       this.accountPassword = accountPassword;
       this.balance = 0.0;
   }
   //定义方法
   public void deposit(double amount){
       balance += amount;
       System.out.println("成功存入" +
               amount+"元。当前余额为："+balance+"元。");
   }
   public void withdraw(double amount){
       if (balance>=amount){
           balance-=amount;
           System.out.println("成功提取"+amount+"元。当前余额为："+balance+"元。");
       }else {
           System.out.println("您的余额不足,取款失败。当前余额为："+balance+"元。");
       }
   }
   public double getBalance(){
       return balance;
   }
}
